/*
 * @Descripttion: 
 * @version: 
 * @Author: wtzhang
 * @Date: 2021-07-05 16:24:14
 * @LastEditors: wtzhang
 * @LastEditTime: 2021-07-06 08:58:05
 */
(function () {
  console.log('******************** 继承 ************************');
  
  class Animal {
    constructor(public name: string, public age: number) {
      this.name = name
      this.age = age 
    }
    say() {
      console.log(`${this.name}: ~~~`);
    }
  }
  
  /**
   * Dog extents Animal
   * - 此时，Animal 被称为父类，Dog 被称为子类
   * Dog extents Animal 使 Dog类 继承 Animal类
   * 使用继承后，子类将拥有父类所有的属性和方法
   */
  class Dog extends Animal {
    // constructor(public name: string, public age: number) {
    //   this.name = name
    //   this.age = age 
    // }
    say() {
      console.log(`${this.name}猫: 汪汪汪`);
    }
  }
  const dog =  new Dog('小黑', 18)
  dog.say()
  
  class Cat extends Animal {
    // constructor(public name: string, public age: number) {
    //   this.name = name
    //   this.age = age 
    // }
    say() {
      console.log(`${this.name}猫: 喵喵喵`);
    }
  }
  const cat =  new Cat('小白', 21)
  cat.say()
})()